package www.huiting.order.controller;

import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.RpcException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;
import www.huiting.user.service.GreeterRequest;
import www.huiting.user.service.IUserApiService;

import java.util.Random;


@RestController
@RequestMapping("order")
public class OrderController {
    @DubboReference
    private IUserApiService userApiService;
    @GetMapping("info")
    public Mono<String> getInfo(){
        return  userApiService.getUserById(Mono.just(GreeterRequest.newBuilder().build()))
                .map(v->v.getMessage())
                .onErrorResume(e->
                        Mono.just("error: " + e.toString())
                );
    }
}
